#include "ListeSorts.h"

#include "FlotMessage.h"

#include <iomanip>

using namespace std;

unsigned afficheSorts(const unsigned& ecole,
		      const unsigned& niveau)
{
FlotMessage& mess = flotMessageGlobal();
  mess << FUNC << "afficheSorts -> début" << endmsg;

  const SortsEcoles *ptr;
  unsigned taille, i;
  bool ok(true);

  switch(ecole)
    {
    case 0:
      ptr = &Abjuration[0];
      taille = 47;
      break;
    case 1:
      ptr = &Alteration[0];
      taille = 146;
      break;
    case 2:
      ptr = &Conjuration[0];
      taille = 60;
      break;
    case 3:
      ptr = &Divination[0];
      taille = 32;
      break;
    case 4:
      ptr = &Enchantement[0];
      taille = 58;
      break;
    case 5:
      ptr = &Illusion[0];
      taille = 56;
      break;
    case 6:
      ptr = &Invocation[0];
      taille = 73;
      break;
    case 7:
      ptr = &Necromancie[0];
      taille = 57;
      break;
    case 8:
      ptr = &Alchimie[0];
      taille = 38;
      break;
    case 9:
      ptr = &Artifices[0];
      taille = 22;
      break;
    case 10:
      ptr = &Dimension[0];
      taille = 22;
      break;
    case 11:
      ptr = &ElementAir[0];
      taille = 23;
      break;
    case 12:
      ptr = &ElementEau[0];
      taille = 23;
      break;
    case 13:
      ptr = &ElementFeu[0];
      taille = 23;
      break;
    case 14:
      ptr = &ElementTerre[0];
      taille = 27;
      break;
    case 15:
      ptr = &Eurythmique[0];
      taille = 43;
      break;
    case 16:
      ptr = &Forces[0];
      taille = 21;
      break;
    case 17:
      ptr = &Geometrie[0];
      taille = 41;
      break;
    case 18:
      ptr = &Mentalisme[0];
      taille = 24;
      break;
    case 19:
      ptr = &Ombres[0];
      taille = 36;
      break;
    case 20:
      ptr = &Universelle[0];
      taille = 17;
      break;
    default:
      mess << WARN << "Erreur dans l'école de magie" << endmsg;
      ok = false;
    }

  if (ok)
    {
      for (i = 0; i < taille; i++, ptr++)
	{
	  if (ptr -> niveau() != niveau)
	    break;
	  mess << BLANK << setw(2) << ptr -> numero() + 1 << ' '
	       << ptr -> nom() << endmsg;
	}

      return i;
    }
  mess << FUNC << "afficheSorts -> fin" << endmsg;
  return 0;
}
